<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      //   // split 把字符串转换为数组和join()相反
      //   const str = "pink,red";
      //   const arr = str.split(",");
      //   console.log(arr);

      //   const str1 = "2024-09-14";
      //   const arr1 = str1.split("-");
      //   console.log(arr1);

      // 字符串截取 substring(开始的索引号,[结束的索引号])
      // 省略最后的索引号，会截取到最后
      // 结束的索引号不包含在截取的内容中
      const str = "字符串截取";
      console.log(str.substring(2, 4));
    </script>
  </body>
</html>
s
